// app.js
App({

  onLaunch() {
    wx.cloud.init({
      env: 'xiaotiao-6gcr9hxy3d8aa90f',
    })

    //获取用户的openid
    let that=this
    wx.cloud.callFunction({
      name:'getOpenId',
      success:res =>{
        console.log("获取openid成功",res.result.openid)
        that.globalData.openid=res.result.openid
      },
      fail:res =>{
        console.log("获取openid失败",res)
      }
    })

    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },

  globalData: {
    userInfo: null,
    openid: "null",
  }
})
